package com.ziq.baselib.test.page

import android.os.Bundle
import com.ziq.base.base.BaseActivity
import com.ziq.base.extension.binding
import com.ziq.base.extension.click
import com.ziq.base.view.TranslateLoadingView
import com.ziq.baselib.databinding.ActivityTranslateLoadingViewBinding

class TranslateLoadingViewActivity: BaseActivity() {

    private val binding : ActivityTranslateLoadingViewBinding by binding()

    private var status: IntArray = intArrayOf(TranslateLoadingView.STATUS_IDLE, TranslateLoadingView.STATUS_SEND, TranslateLoadingView.STATUS_RECEIVE)
    private var index: Int = 0

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.root
        binding.translateLoadingView.setStatus(TranslateLoadingView.STATUS_IDLE)
        binding.next.click {
            index++
            if (index >= status.size) {
                index = 0
            }
            binding.translateLoadingView.setStatus(status[index])
        }
        binding.last.click {
            index--
            if (index < 0) {
                index = status.size - 1
            }
            binding.translateLoadingView.setStatus(status[index])
        }
    }

}